473,468 Members | 1,586 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Select dropdown

Hi,
is there a possibility to change the size of the select-dropdown-box ?
I predefine the length of the option-area with 10 inside HTML as
follows:

<select class="select250" name="projectTypeSelect">
<script language="JavaScript"
type="text/javascript">document.lopForm.projectTypeSelect.opt ions.length=10;</script>
</select>

The resulting dropdown-box will be 10 rows long.

If I have less entries, let's say 4, there will be 6 empty rows and I
want to shorten
the dopdownbox to 4 rows.

Anyone knowing a way to do this ?

Thanks
Wolfgang

Dec 14 '06 #1
2 1814
Wolfgang wrote:
Hi,
is there a possibility to change the size of the select-dropdown-box ?
I predefine the length of the option-area with 10 inside HTML as
follows:

<select class="select250" name="projectTypeSelect">
<script language="JavaScript"
type="text/javascript">document.lopForm.projectTypeSelect.opt ions.length=10;</script>
</select>

The resulting dropdown-box will be 10 rows long.

If I have less entries, let's say 4, there will be 6 empty rows and I
want to shorten
the dopdownbox to 4 rows.

Anyone knowing a way to do this ?
Hi,

You can simply find all individual options inside a SELECT via:
document.formname.selectname.options.
It will return an array with Option objects in them.
on each Option you can get the text and value.

In your case you can remove the options that contain no text or no value.
You can remove an option by setting the value to null (in the array that
contains the options).

But I wonder why you add 10 options in the first place...
Why not just add what you need?

Regards,
Erwin Moller
>
Thanks
Wolfgang
Dec 14 '06 #2
ASM
Wolfgang a écrit :
Hi,
is there a possibility to change the size of the select-dropdown-box ?
I predefine the length of the option-area with 10 inside HTML as
follows:
why not to have a dropdown of 0 option (length = 0)
and increase it step by step ?
var S = document.lopForm.projectTypeSelect.options;
S.length = 0;
for(var i=0; i<4; i++)
{
var o = new Option('text '+i, 'val '+i);
S[S.length] = o;
}


--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dec 14 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jas | last post by:
I want an ASP page with a dropdown and a simple button. Every time the user chooses an item from the dropdown and clicks on the button i want that value written below in list and allow user to...
1
by: Rod Early | last post by:
I need to know when the select element's dropdown list is opened (as when the user clicks on the arrow or does ALT-downarrow from the keyboard). Similarly, I need to known when the dropdown list...
5
by: Ganco | last post by:
We have a dropdown combobox, where some of the text is wider than the textarea. I cannot set the width of the SELECT any higher due to design restrictions on the company website. When clicking...
9
by: Prowler | last post by:
In our current application we have a page whose sole purpose for existence is to permit the user to select from a list (subsequent to our login page). We would like to have the list drop down...
6
by: passion_to_be_free | last post by:
This is probably simple, but I can't seem to find it anywhere. I have have some values stored in javascript variables. I have a <select> dropdown list whose options correspond to these values. I...
2
by: hypomite | last post by:
I have an handler for the SelectedIndexChanged event of a dropdown box. I have also set the AutoPostBack option to True. When you select any item besides the first one, the event sucessfully fires....
5
by: balu435 | last post by:
Hi friends, I have an (VBA) application which programatically fills the options in a web page. I have an dropdown menu whose options are selected during run-time by using a function.Is there...
4
by: =?Utf-8?B?c2lMdmVy?= | last post by:
Hhi, I'm working on an asp .net project that have small side panel which 'disallow' long SELECT/dropdown list.. So i could not force them to a certain that shows my longest option, which now...
1
by: RichardR | last post by:
I have a webpage which has a table that contains a column with several drop down boxes (<SELECT>). The contents of the drop down boxes are dynamically populated so I have no idea what the actually...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.